home *** CD-ROM | disk | FTP | other *** search
/ PC User 2002 April / Disc 2 / PCUSER0402D2.iso / software / utils / files / wincron.exe / data1.cab / Sample_Scripts / ftp_basic_test.tg < prev    next >
Encoding:
Text File  |  2001-10-20  |  4.7 KB  |  153 lines

  1. ## ftp_master_test.tab
  2. # Perform many FTP functions while handling exceptions.
  3. # Basically, this script does recursive Get, Put, and Delete as well as Rename and Test.
  4. # script assumes:
  5. # 1. There is a temp/foo directory on the remote server 
  6. # 2. There is a temp/foo/test_file.dat file on the remote server 
  7. # 3. There is a c:\temp\foo local directory (tree) filled with all the files and directories
  8. #    you wish to move back and forth.
  9. # 4. the environment variables: USER.SERVER, USER.USERID, and USER.PASSWORD are set elsewhere,
  10. #    perhaps in the global (computer) environment or the local environment of WinCron via 
  11. #    Config.tg or AutoRun.tg. You could also set them here in this this script or hard-code the 
  12. #    values passed to -ftp connect.
  13. {
  14.     -name ftp_master_test
  15.     -start 
  16.     #-stop
  17.  
  18.     # tell user what we are about to do
  19.     -action -print ftp master test
  20.  
  21.     # setup local environment
  22.     -action -set LOCAL_DIR=c:\temp\foo
  23.     
  24.     # I set these in my global environment, you can set them here
  25.     #-action -set USER.SERVER=xxx
  26.     #-action -set USER.USERID=yyy
  27.     #-action -set USER.PASSWORD=zzz
  28.  
  29.     # CONNECT TO FTP SERVER
  30.     -action -print connecting to remote ftp server
  31.     -action -onerror connect_fail
  32.     -action -ftp connect handle %USER.SERVER% 21 %USER.USERID% %USER.PASSWORD%
  33.  
  34.     # DEBUG
  35.     #-action -print lastline: %FTP.LASTLINE%
  36.  
  37. # TEST FOR "test-file" ON REMOTE SERVER
  38. -action -print testing for "test-file" on remote ftp server
  39. -action -set OPERATION=test1
  40. -action -onerror general_failure
  41. -action -ftp test handle temp/foo/test_file.dat
  42.  
  43.     # DEBUG
  44.     #-action -print lastline: %FTP.LASTLINE%
  45.  
  46.     # GET A FILE FROM REMOTE SERVER
  47.     -action -print getting file from remote ftp server
  48.     -action -set OPERATION=get
  49.     -action -onerror general_failure
  50.     -action -ftp get handle temp/foo/test_file.dat %LOCAL_DIR%\test_file.dat 0
  51.  
  52.     # DEBUG
  53.     #-action -popup Did we get test_file.dat to %LOCAL_DIR%\test_file.dat?
  54.     #-action -print lastline: %FTP.LASTLINE%
  55.  
  56.     # DELETE THE test-file FROM REMOTE SERVER
  57.     -action -print deleting the file from remote ftp server
  58.     -action -set OPERATION=del
  59.     -action -onerror general_failure
  60.     -action -ftp del handle temp/foo/test_file.dat
  61.  
  62.     # DEBUG
  63.     #-action -popup Has temp/foo/test_file.dat been deleted?
  64.     #-action -print lastline: %FTP.LASTLINE%
  65.  
  66.     # PUT A FILE ON REMOTE SERVER
  67.     -action -print putting file back on remote ftp server
  68.     -action -set OPERATION=put
  69.     -action -onerror general_failure
  70.     -action -ftp put handle %LOCAL_DIR%\test_file.dat temp/foo/test_file.dat 0
  71.  
  72.     # DEBUG
  73.     #-action -popup Is temp/foo/test_file.dat back again?
  74.     #-action -print lastline: %FTP.LASTLINE%
  75.  
  76. # TEST FOR "test-file" ON REMOTE SERVER
  77. -action -print testing for "test-file" on remote ftp server
  78. -action -set OPERATION=test2
  79. -action -onerror general_failure
  80. -action -ftp test handle temp/foo/test_file.dat
  81.  
  82.     # DEBUG
  83.     #-action -print lastline: %FTP.LASTLINE%
  84.  
  85.     # RENAME "test-file" ON REMOTE SERVER
  86.     -action -print rename the test-file on remote ftp server
  87.     -action -set OPERATION=rename
  88.     -action -onerror general_failure
  89.     -action -ftp rename handle temp/foo/test_file.dat temp/foo/test_file.bak
  90.  
  91.     # DEBUG
  92.     #-action -popup Was temp/foo/test_file.dat renamed to temp/foo/test_file.bak?
  93.     #-action -print lastline: %FTP.LASTLINE%
  94.  
  95. # TEST FOR test_file.bak ON REMOTE SERVER
  96. -action -print testing for test-file.bak on remote ftp server
  97. -action -set OPERATION=test3
  98. -action -onerror general_failure
  99. -action -ftp test handle temp/foo/test_file.bak
  100.  
  101.     # DEBUG
  102.     #-action -print lastline: %FTP.LASTLINE%
  103.  
  104.     # RENAME "test-file" ON REMOTE SERVER
  105.     -action -print rename the test-file on remote ftp server
  106.     -action -set OPERATION=rename
  107.     -action -onerror general_failure
  108.     -action -ftp rename handle temp/foo/test_file.bak temp/foo/test_file.dat
  109.  
  110.     # DEBUG
  111.     #-action -popup has temp/foo/test_file.dat been restored?
  112.     #-action -print lastline: %FTP.LASTLINE%
  113.  
  114. # TEST FOR "test-file" ON REMOTE SERVER
  115. -action -print testing for "test-file" on remote ftp server
  116. -action -set OPERATION=test4
  117. -action -onerror general_failure
  118. -action -ftp test handle temp/foo/test_file.dat
  119.  
  120.     # DEBUG
  121.     #-action -print lastline: %FTP.LASTLINE%
  122.  
  123.     # CLOSE FTP CONNECTION
  124.     -action -print closing ftp connection
  125.     -action -ftp close handle 
  126.  
  127.     # DEBUG
  128.     #-action -print lastline: %FTP.LASTLINE%
  129.  
  130.     -action -print done!
  131.  
  132.     -action -inc 0 0 0 1
  133. }
  134.  
  135. # connection failed
  136. {
  137.     -name connect_fail
  138.     -action -print FTP open connection failed with error:
  139.     -action -print %FTP.ERROR%
  140.     -action -return abort
  141. }
  142.  
  143. # general failed
  144. {
  145.     -name general_failure
  146.     -action -print FTP %OPERATION% failed with error:
  147.     -action -print %TG.LAST_ERROR%
  148.     -action -print Closing connection.
  149.     -action -ftp close handle
  150.     -action -return abort
  151. }
  152.  
  153.